<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<div class="container-fluid am-margin">
    <form id="adminDivForm">
        <input type="hidden" name="id"/>
        <input type="hidden" name="pid"/>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label for="name">名称</label>
                        <input type="text" name="name" class="form-control" check-type="required">
                    </div>
                </div>
                 <div class="col-sm-6">
                    <div class="form-group">
                        <label for="code">行政区划编码</label>
                        <input type="text" name="code" class="form-control" check-type="required">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <a href="javascript:void(0)" id="adminDivSaveBt"  class="btn btn-primary pull-right">保存</a>
            </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var adminDivForm = $("#adminDivForm");
        var pid = '${param.pid}';
        var id = '${param.id}';
        adminDivForm.find("input[name=pid]").val(pid);
        adminDivForm.validation();
        if (id) {
            $.getJSON(ctx + '/adminDivAct/findById.do', {id: id}, function (data) {
                webUtils.fullForm({
                    form: adminDivForm,
                    data: data
                });
            });
        }
        $("#adminDivSaveBt").click(function () {
        	if(adminDivForm.valid()){
        		adminDivForm.ajaxSubmit({
                    url: ctx + '/adminDivAct/save.do',
                    data: {},
                    type: "POST",
                    success: function (data) {
                        if (data.success) {
                        	webUtils.alert("提交成功");
                            top.webUtils.topicPublish("adminDivTree.edit.success", data);
                        } else {
                        	webUtils.error(data.msg);
                        }
                    }
                });
        	}
        });
    });
</script>